/*
 * Move.cpp
 *
 *  Created on: 13.10.2010
 *      Author: jilly
 */

#include "Move.h"
#include <iostream>

using namespace std;

Move::Move(int who, unsigned int fromX, unsigned int fromY, unsigned int toX, unsigned int toY)
{
	this->who = who;
	this->fromX = fromX;
	this->fromY = fromY;
	this->toX = toX;
	this->toY = toY;
}


Move::Move(Move* other)
{
	this->who = other->who;
	this->fromX = other->fromX;
	this->fromY = other->fromY;
	this->toX = other->toX;
	this->toY = other->toY;
	this->hit = other->hit;
}
Move* Move::clone()
{
	return new Move(this);
}

Move::~Move() {
	//cout << "deleting move ";
	//print();
	//cout << endl;
}

int Move::getWho() const
{
	return who;
}

unsigned int Move::getFromX() const
{
	return fromX;
}

unsigned int Move::getFromY() const
{
	return fromY;
}

unsigned int Move::getToX() const
{
	return toX;
}

unsigned int Move::getToY() const
{
	return toY;
}

bool Move::wasHit() const
{
	return hit;
}

void Move::setHit(bool hit)
{
	this->hit = hit;
}

void Move::print()
{
	cout << "Move of:	" << ((who == MOVE_QUEEN) ? "Queen" : "Bishop") << endl;
	cout << "Move from:	" << "[" << getFromX() << "," << getFromY() << "]" << endl;
	cout << "Move to:	" << "[" << getToX() << "," << getToY() << "]" << endl;
}

void Move::write(ofstream& stream)
{
	stream << "Move of:	" << ((who == MOVE_QUEEN) ? "Queen" : "Bishop") << endl;
	stream << "Move from:	" << "[" << getFromX() << "," << getFromY() << "]" << endl;
	stream << "Move to:	" << "[" << getToX() << "," << getToY() << "]" << endl;
}
